package com.all.ui;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import com.all.base.BaseActivity;
import com.all.common.ActionBarManager;
import com.all.utils.StringUtils;
import com.all.utils.ToastUtils;

public class FeedbackActivity extends BaseActivity {

	private EditText et_message;
	//private final static String FEED_BACK_URL = "";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_feedback);
	}
	
	public void initView(View view) {
		et_message = (EditText)findViewById(R.id.et_message);
		
		//初始化返回按钮
		//String strCenterTitle = getResources().getString(R.string.FeedbackActivity);
		//ActionBarManager.initBackTitle(getContext(), getActionBar(), strCenterTitle);
	}


	/**
	 * 表单验证
	 * @return
	 */
	private boolean validateForm(){
		String strMessage = et_message.getText().toString();
		if(StringUtils.isEmpty(strMessage)){
			return true;
		}else{
			ToastUtils.showShort(getContext(), "请输入意见内容再提交，谢谢");
			return false;
		}
	}

	@Override
	public void onClick(View view) {
		// TODO Auto-generated method stub
		switch (view.getId()) {  
        case R.id.btn_sumbit:  
        	//提交表单
			if(validateForm()){
				//需要设置表单元素控件的tag属性，作为表单提交的key
//				DTO<String,Object> form = ToolData.gainForm(root, new DTO<String,Object>());
//				ToolHTTP.post(FEED_BACK_URL, form, getFeedBackHandler());
			}
            break;  
        default:  
            break;  
        }  
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		//渲染菜单
		getMenuInflater().inflate(R.menu.actionbar_menu, menu);  				
		//根据业务需要订制菜单
		ActionBarManager.initActionBarSubmitButton(menu,R.id.action_submit);
  
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {  
			case R.id.action_submit:
				if(validateForm()){
					//启动线程异步传送数据.
					
				}
				break;
		}
		return super.onOptionsItemSelected(item);
	}
	
	
}

